/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package src.com.negocio.pedagogico;

import src.com.dados.pedagogico.NivellDao;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

/**
 *
 * @author Giane
 */
public class ConsultarNivelCurso {

    public String consultaIdioma(String idioma) throws SQLException {
    NivellDao niv = new NivellDao();
    return niv.id_idioma(idioma);
   }

    public ArrayList<String> consultaNivel(String id_Idioma) throws SQLException {
        Connection conexao;
        ArrayList<String> result = new ArrayList<String>();
        String select_niveis = "SELECT nvl_nome FROM bdeng2.nvl_nivel where nvl_id_idioma = "+ id_Idioma +" ;";
        String url = "jdbc:mysql://localhost/bdeng2";
        DriverManager.registerDriver(new com.mysql.jdbc.Driver());
        //Class.forName("com.mysql.jdbc.Driver");
        conexao = DriverManager.getConnection(url, "root", "dados");
        //System.out.println("2 - " + select_ano);

        PreparedStatement stmt = conexao.prepareStatement(select_niveis);
        ResultSet rs = stmt.executeQuery();

        while (rs.next()) {
            result.add(rs.getString(1));
            // System.out.println(rs.getString(1));
        }

        conexao.close();
        return result;

    }

    public String consultaValor(String nivel) throws SQLException {
       NivellDao vl = new NivellDao();
       return vl.consultaValor(nivel);
    }
    
}
